﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Markup;
using System.Windows.Media.Imaging;

namespace WPF.TreeView
{
    public class StatusToImageSourceConverter : MarkupExtension, IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool sts = (bool)value;
            if (sts)
            {
                return new BitmapImage(new Uri(@"..\Images\圆形选中32.png", UriKind.Relative));
            }
            else
            {
                return new BitmapImage(new Uri(@"..\Images\圆形未选中32.png", UriKind.Relative));
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return new StatusToImageSourceConverter();
        }
    }
}
